package ${cfg.VO};

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.time.LocalDateTime;
<#if entityLombokModel>
    import lombok.Data;
    import lombok.Builder;
    import lombok.EqualsAndHashCode;
    import lombok.NoArgsConstructor;
    import lombok.AllArgsConstructor;
    import com.fasterxml.jackson.annotation.JsonInclude;
    import lombok.ToString;
    import lombok.experimental.Accessors;
    import com.eastfair.annotation.annotation.vo.VoInfo;
    import com.eastfair.annotation.model.BaseVoGroupClass;
</#if>
<#list cfg.filedTypes as fieldType>
    <#list table.fields as field>
        <#if field.propertyName == fieldType.name && table.name==fieldType.table && field.propertyType=="String">
            import ${fieldType.packagePath};
            <#break>
        </#if>
    </#list>
</#list>
import java.io.Serializable;
import com.eastfair.vo.BaseVO;

/**
* <p>
    * 实体类
    * ${table.comment!?replace("\n","\n * ")}
    * </p>
*
* @author ${author}
* @since ${date}
*/
<#if entityLombokModel>
    @Data
</#if>
<#if swagger2>
    @ApiModel(value = "${entity}VO", description = "${table.comment!?replace("\r\n"," ")?replace("\r"," ")?replace("\n"," ")}")
</#if>
public class ${entity}VO extends BaseVO implements Serializable {

private static final long serialVersionUID = 1L;

<#list table.commonFields as field>
    <#if field.keyFlag>
        @ApiModelProperty(value = "主键")
        @JsonInclude(JsonInclude.Include.NON_NULL)
        @VoInfo(groups = {BaseVoGroupClass.all.class})
        private ${field.propertyType} ${field.propertyName};
    </#if>
</#list>

<#list table.fields as field>
<#-- 如果有父类，排除公共字段 -->
    <#if (superEntityClass?? && cfg.superExtend?? && field.propertyName !="id") || (superEntityClass?? && field.propertyName !="id" && field.propertyName !="createTime" && field.propertyName != "updateTime" && field.propertyName !="createUser" && field.propertyName !="updateUser") || !superEntityClass??>
        <#if field.keyFlag>
            <#assign keyPropertyName="${field.propertyName}"/>
        </#if>
        <#assign fieldComment="${field.comment!}"/>
        <#if field.comment!?length gt 0>
            /**
            * ${field.comment!?replace("\n","\n     * ")}
            */
            <#if field.comment!?contains("\n") >
                <#assign fieldComment="${field.comment!?substring(0,field.comment?index_of('\n'))?replace('\r\n','')?replace('\r','')?replace('\n','')?trim}"/>
            </#if>
        </#if>
        <#if swagger2>
            @ApiModelProperty(value = "${fieldComment}")
            @JsonInclude(JsonInclude.Include.NON_NULL)
        </#if>
        <#assign myPropertyType="${field.propertyType}"/>
        <#assign isEnumType="1"/>
        <#list cfg.filedTypes as fieldType>
            <#if fieldType.name == field.propertyName && table.name==fieldType.table && field.propertyType=="String">
                <#assign myPropertyType="${fieldType.type}"/>
                <#assign isEnumType="2"/>
            </#if>
        </#list>
        <#if field.customMap.dict??>
            <#assign isEnumType="3"/>
        </#if>
        <#if field.customMap.Null == "NO" >
            <#if (field.columnType!"") == "STRING" && isEnumType == "1">
                @NotEmpty(message = "请填写${fieldComment}")
            <#else>
                @NotNull(message = "请填写${fieldComment}")
            </#if>
        </#if>
        <#if (field.columnType!"") == "STRING" && isEnumType == "1">
            <#assign max = 255/>
            <#if field.type?starts_with("varchar") || field.type?starts_with("char")>
                <#if field.type?contains("(")>
                    <#assign max = field.type?substring(field.type?index_of("(") + 1, field.type?index_of(")"))/>
                </#if>
                @Size(max = ${max}, message = "${fieldComment}长度不能超过${max}")
            <#elseif field.type?starts_with("text")>
                <#assign max = 65535/>
                @Size(max = ${max?string["0"]}, message = "${fieldComment}长度不能超过${max}")
            <#elseif field.type?starts_with("mediumtext")>
                <#assign max = 16777215/>
                @Size(max = ${max?string["0"]}, message = "${fieldComment}长度不能超过${max}")
            <#elseif field.type?starts_with("longtext")>
            </#if>
        <#else>
            <#if field.propertyType?starts_with("Short")>
                @Size(min = Short.MIN_VALUE, max = Short.MAX_VALUE, message = "${fieldComment}长度不能超过"+Short.MAX_VALUE)
            </#if>
            <#if field.propertyType?starts_with("Byte")>
                @Size(min = Byte.MIN_VALUE, max = Byte.MAX_VALUE, message = "${fieldComment}长度不能超过"+Byte.MAX_VALUE)
            </#if>
            <#if field.propertyType?starts_with("Short")>
                @Size(min = Short.MIN_VALUE, max = Short.MAX_VALUE, message = "${fieldComment}长度不能超过"+Short.MAX_VALUE)
            </#if>
        </#if>
        <#if field.customMap.dict??>
            @DictionaryType("${field.customMap.dict}")
            <#assign myPropertyType="Dictionary"/>
        </#if>
        <#assign myPropertyName="${field.propertyName}"/>
    <#-- 自动注入注解 -->
    <#--    <#if field.customMap.annotation??>-->
    <#--        <#assign myPropertyType="${field.customMap.type}"/>-->
    <#--        <#if field.propertyName?ends_with("Id")>-->
    <#--            <#assign myPropertyName="${field.propertyName!?substring(0,field.propertyName?index_of('Id'))}"/>-->
    <#--        </#if>-->
    <#--    </#if>-->
        private ${myPropertyType} ${myPropertyName};
    </#if>
</#list>
<#if superEntityClass?? && superEntityClass=="TreeEntity">
    @ApiModelProperty(value = "名称")
    @NotEmpty(message = "请填写名称")
    @Size(max = 255, message = "名称长度不能超过255")
    protected String label;

    @ApiModelProperty(value = "父ID")
    protected <#list table.commonFields as field><#if field.keyFlag>${field.propertyType}</#if></#list> parentId;

    @ApiModelProperty(value = "排序号")
    protected Integer sortValue;
</#if>
}
